home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Resources / Online / Miami / MiamiSDK / netinclude / machine / endian.h < prev    next >
C/C++ Source or Header  |  1997-12-04  |  1KB  |  45 lines

  1. #ifndef _MACHINE_ENDIAN_H_
  2. #define    _MACHINE_ENDIAN_H_
  3.  
  4. #ifndef _SYS_TYPES_H_
  5. #include <sys/types.h>
  6. #endif
  7.  
  8. /*
  9.  * Definitions for byte order, according to byte significance from low
  10.  * address to high.
  11.  */
  12. #define    LITTLE_ENDIAN    1234    /* LSB first: i386, vax */
  13. #define    BIG_ENDIAN    4321    /* MSB first: 68000, ibm, net */
  14. #define    PDP_ENDIAN    3412    /* LSB first in word, MSW first in long */
  15.  
  16. #define    BYTE_ORDER    BIG_ENDIAN
  17.  
  18. unsigned long    htonl(unsigned long);
  19. unsigned short    htons(unsigned short);
  20. unsigned long    ntohl(unsigned long);
  21. unsigned short    ntohs(unsigned short);
  22.  
  23. /*
  24.  * Macros for network/external number representation conversion.
  25.  */
  26. #if BYTE_ORDER == BIG_ENDIAN && !defined(lint)
  27. #define    ntohl(x)    (x)
  28. #define    ntohs(x)    (x)
  29. #define    htonl(x)    (x)
  30. #define    htons(x)    (x)
  31.  
  32. #define    NTOHL(x)    (x)
  33. #define    NTOHS(x)    (x)
  34. #define    HTONL(x)    (x)
  35. #define    HTONS(x)    (x)
  36.  
  37. #else
  38.  
  39. #define    NTOHL(x)    (x) = ntohl((u_long)x)
  40. #define    NTOHS(x)    (x) = ntohs((u_short)x)
  41. #define    HTONL(x)    (x) = htonl((u_long)x)
  42. #define    HTONS(x)    (x) = htons((u_short)x)
  43. #endif
  44. #endif /* !_ENDIAN_H_ */
  45.